export const state = () => ({
    post: []
})
export const mutations = {
    setDraft(state, data) {
        var flag = state.post.some(
            item =>
                item.title == data.title &&
                item.content == data.content &&
                item.city == data.city
        );
        if (!flag) {
            state.post.unshift(data)
        } else {
            alert('请勿保存重复的草稿！')
        }
        if (state.post.length > 5) {
            state.post = state.post.slice(0, 5);
        }
    },
    delDraft(state, data) {
        state.post.splice(data, 1)
    }
}